CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

MACRO(MAP_PUT _MAP _KEY _VALUE)
	SET("MAP_${_MAP}_${_KEY}" ${_VALUE})
ENDMACRO()

MACRO(MAP_GET _MAP _KEY _OUTPUT)
	SET(KEY "MAP_${_MAP}_${_KEY}")
	if(${KEY})
		SET(${_OUTPUT} ${${KEY}})
	else()
		SET(${_OUTPUT} "undefined")
	endif()
ENDMACRO()

MACRO(LOAD_PROPERTY _MAP _FILENAME)
	FILE(READ ${_FILENAME} contents)
	STRING(REGEX REPLACE "\n" ";" lines "${contents}")
	foreach(line ${lines})
		if(NOT (${line} MATCHES "^(#|\t|\n| )"))
			STRING(REGEX REPLACE "\t+| +|=|:" ";" fields ${line})
			list(GET fields 0 KEY)
			list(GET fields 1 VALUE)
			#MESSAGE("KEY = ${KEY}")
			#MESSAGE("VALUE = ${VALUE}")
			MAP_PUT(${_MAP} ${KEY} ${VALUE})
		endif()
	endforeach()
ENDMACRO()